package com.wk.sms.controller;

import com.wk.common.bean.Resp;
import com.wk.sms.entity.SkuBounds;
import com.wk.sms.service.SkuBoundsService;
import com.wk.sms.vo.SaleVO;
import com.wk.sms.vo.SkuSaleVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/skubounds")
public class SkuBoundsController {

    @Autowired
    private SkuBoundsService skuBoundsService;

    /**
     * 根据skuId查询营销信息
     * @param skuId
     * @return
     */
    @GetMapping("{skuId}")
    public Resp<List<SaleVO>> querySaleVOBySkuId(@PathVariable(value = "skuId") Long skuId) {
        List<SaleVO> saleVOs = skuBoundsService.querySaleVOBySkuId(skuId);
        return Resp.ok(saleVOs);
    }

    /**
     * 保存数据到营销信息相关的三张表
     * 添加spu方法中使用 通过feign调用 json传递参数
     */
    @PostMapping("saveSaleAttr")
    public Resp<Void> saveSaleAttr(@RequestBody SkuSaleVO skuSaleVO){
        skuBoundsService.saveSaleAttr(skuSaleVO);
        return Resp.ok(null);
    }

}

